#include <stdio.h>
#include <stdlib.h>
#include "LinkedList.h"

void printList(struct linkedList* list)
{
	struct node* current = list->head;

	printf("Len: %d (", list->length);
	
	while(current != NULL)
	{
		printf("%d, ", current->data);
		current = current->next;
	}

	printf("...)\n");
}

struct linkedList* buildList()
{
	struct linkedList* list = createList();
	addToEndOfList(&list, 1);
	addToEndOfList(&list, 2);
	addToEndOfList(&list, 18);
	addToEndOfList(&list, 8);
	addToEndOfList(&list, 3);
	addToEndOfList(&list, 6);
	addToEndOfList(&list, 7);
	addToEndOfList(&list, 0);

	return list;
}

void main()
{
	struct linkedList* list = buildList();
	printList(list);

	addToStartOfList(&list, -89);
	addToEndOfList(&list, 10);

	printList(list);

	bubbleSort(&list);

	printf("After bubble sort:\n");

	printList(list);

	// tidy up
	free (list);
}